//不使用C语言库函数从文件里面读取内容并打印
//向命令行输出也只能用系统调用函数，不允许用C库函数
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

int main(int argc,char*argv[])
{
    if(argc < 2)
	{
		printf("argument too few in %s at %d\n",__FILE__,__LINE__);
		return 1;
	}
    int fd = -1;
	char ch = '\0';

	fd = open(argv[1],O_RDONLY);
	if(fd < 0)
	{
		printf("Open %s failed,in %s at %d\n",argv[1],__FILE__,__LINE__);
		return 1;
	}
	//printf("fd=%d\n",fd);

    while(read(fd,&ch,1) == 1)
    {
        write(1,&ch,1);
    }

	close(fd);
	fd = -1;
    return 0;
}